package com.zhengqiangblog.blog.service;

import java.util.List;

import org.apache.log4j.Logger;

import com.zhengqiangblog.blog.model.Archive;
import com.zhengqiangblog.blog.model.Category;
import com.zhengqiangblog.blog.model.HotTag;
import com.zhengqiangblog.core.ApplicationContext;
import com.zhengqiangblog.core.Model;

public class SideBarService {

	private static final Logger logger = Logger.getLogger(SideBarService.class);

	private ArticleService articleService = ApplicationContext.get(ArticleService.class);
	private CategoryService categoryService = ApplicationContext.get(CategoryService.class);
	private ArticleTagService articleTagService = ApplicationContext.get(ArticleTagService.class);

	public SideBarService() {
		logger.info("SideBarService initializing...");
	}

	public void initialize(Model model) throws Exception {
		List<Category> categories = categoryService.getCategoryList();
		model.addAttribute("categories", categories);
		List<Archive> archives = articleService.getArchives();
		model.addAttribute("archives", archives);
		List<HotTag> hotTags = articleTagService.getHotTags(10);
		model.addAttribute("hotTags", hotTags);
	}

}
